package com.ioffice.export.excel.sheet;

import java.util.List;

import com.ioffice.exception.IOfficeException;
import com.ioffice.export.excel.sheet.cell.SheetCell;

/**
 * 
 * @author <a href="mailto:goodluck.sunlight@gmail.com">chenboning</a>
 *
 * 
 * @descption Sheet 组件
 *
 * @version 1.0
 *
 *
 * @time  2013-5-21  上午10:08:14
 */
public abstract class SheetGeneric {

	/**
	 * x的坐标
	 */
	private int x=0;
	/**
	 * y的坐标
	 */
	private int y=0;
	/**
	 * 组件的横跨多少列
	 */
	private int xspan=1;
	/**
	 * 组件的纵跨多少列
	 */
	private int yspan=1;
	
	protected List<SheetCell> child=null;
	
	public SheetGeneric() {
		initChild();
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getXspan() {
		return xspan;
	}

	public void setXspan(int xspan) {
		this.xspan = xspan;
	}

	public int getYspan() {
		return yspan;
	}

	public void setYspan(int yspan) {
		this.yspan = yspan;
	}
	
	protected abstract void initChild();
	
	public void addChild(SheetCell cell)throws IOfficeException{
		if(child!=null){
			child.add(cell);
		}else{
			throw new IOfficeException("children  is null , not inistance");
		}
	}
	
	public int getChildSize()throws IOfficeException{
		if(child!=null)
			return this.child.size();
		else{
			throw new IOfficeException("children  is null , not inistance");
		}	
	}
	
	public List<SheetCell> getChild(){
		return this.child;
	}
	
	public SheetCell getSheetCell(int index){
		return this.child.get(index);
	}
}
